package vip.zhenzicheng.design_patterns.singleton.lazy;

/**
 * 懒汉式1 (线程不安全)
 *
 * @author zhenzicheng
 * @date: 2022-05-24 22:56
 */
public class SingletonWithCheck {
  private static SingletonWithCheck INSTANCE;

  private SingletonWithCheck() {
  }

  public static SingletonWithCheck getInstance() {
    if (INSTANCE == null) { // 线程不安全，非常可能在多线程竞争情况下导致不是单例
      INSTANCE = new SingletonWithCheck();
    }
    return INSTANCE;
  }

}
